package com.xy.biz.uc.domain.converter;

import com.xy.biz.uc.domain.bo.TeamBO;
import com.xy.biz.uc.domain.po.TeamPO;
import com.xy.biz.uc.domain.query.TeamQuery;
import com.xy.biz.uc.domain.req.ListTeamRequest;
import com.xy.biz.uc.domain.req.SaveTeamRequest;
import com.xy.biz.uc.domain.resp.GetTeamResponse;
import com.xy.tool.util.BeanUtilsEx;

import java.util.Collection;
import java.util.List;

/**
 *
 *
 * @author yzh
 * @date 2021-4-26
 */
public class TeamConverter {

	public static TeamPO toPO(TeamBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new TeamPO(), true);
	}

	public static List<TeamPO> toPO(Collection<TeamBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new TeamPO(), true);
	}

	public static TeamBO fromPO(TeamPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new TeamBO());
	}

	public static List<TeamBO> fromPO(Collection<TeamPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new TeamBO());
	}

	public static TeamBO toBO(SaveTeamRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new TeamBO(), true);
	}

	public static List<TeamBO> toBO(Collection<SaveTeamRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new TeamBO(), true);
	}

	public static GetTeamResponse toResponse(TeamBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetTeamResponse());
	}

	public static List<GetTeamResponse> toResponse(Collection<TeamBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetTeamResponse());
	}

	public static TeamQuery toQuery(ListTeamRequest source) {
		if(null == source) {
			return null;
		}
		TeamQuery target = new TeamQuery();
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
